#ifndef ELEMENT_H
#define ELEMENT_H

#include <QObject>
#include<Eigen/Core>
#include<vector>
#include <QOpenGLFunctions>
#include <QOpenGLShaderProgram>
#include <QOpenGLTexture>
#include <QOpenGLVertexArrayObject>
#include <QOpenGLBuffer>
#include <QDebug>
#include <QOpenGLWidget>

enum ElementType {Cloud, Line, Plane, Circle, Cylinder, Cone};

class Element : public QObject, protected QOpenGLFunctions
{
    Q_OBJECT
public:
    Element(QObject *parent = nullptr);
    virtual bool fit(const std::vector<Eigen::Vector3d>& points);
    void loadGL(QOpenGLWidget *gl);
    virtual void Draw(QOpenGLShaderProgram &shader)=0;
    virtual QString Info()=0;
    std::vector<Eigen::Vector3d> vertices; // 存储点集
signals:

protected:
    QOpenGLVertexArrayObject VAO;
    QOpenGLBuffer EBO;
    QOpenGLBuffer VBO;
    ElementType type;
    std::vector<int> index; // 存储类型
    double len;
};

#endif // ELEMENT_H
